#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""


class Solution:
    def maxProduct(self, nums):
        l = len(nums)
        self.max_positive = [1] * (l)
        self.min_negative = [1] * (l)

        if nums[0] >= 0:
            self.max_positive[0] = nums[0]
        else:
            self.min_negative[0] = nums[0]

        g_max = nums[0]

        for i in range(1, l):
            n = nums[i]

            if n == 0:
                self.max_positive[i] = 0
                self.min_negative[i] = 0

            if n > 0:
                self.max_positive[i] = max(n, n * self.max_positive[i-1])
                self.min_negative[i] = min(n, n * self.min_negative[i-1])
            else:
                self.max_positive[i] = max(n, n * self.min_negative[i-1])
                self.min_negative[i] = min(n, n * self.max_positive[i-1])

            g_max = max(g_max, self.max_positive[i])

        print(self.max_positive)
        print(self.min_negative)
        return g_max


def main():
    print("start main")
    s = Solution()
    l = [2,3,-2,4]
    print(l)
    ret = s.maxProduct(l)
    print(ret)

if __name__ == "__main__":
    main()
